﻿@using ST.Buz.Base.ViewModel
@model VM_Login
@{
	Layout = null;
}

<!DOCTYPE html>
<html lang="zh">
<head>
	<title>@ViewBag.SysName</title>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	@*<meta name="viewport" content="width=device-width, initial-scale=1">*@
	<meta name="description" content="" />
	<meta name="keywords" content="" />
	<meta name="author" content="" />
	<meta name="renderer" content="webkit">
	<link href="~/css/login.css" rel="stylesheet" asp-append-version="true" />
	<script>
		var globalData = {
			modules: [],
			user: {},
			baseUrl: '@(Context.Request.PathBase)',
			loginUrl:'@(Url.Action("Login","Sys_User"))'
		};
	</script>
</head>

<body class="loginbody">
	<!--[if lt IE 11]>
	<div style='border: 1px solid #F7941D; background: #FEEFDA; text-align: center; clear: both; height: 75px; position: relative;'>
		<div style='position: absolute; right: 3px; top: 3px; font-family: courier new; font-weight: bold;'>
			<img src='~/img/remove.gif' style='border: none;cursor:pointer;margin-top:10px;'
				 onclick='this.parentNode.parentNode.style.display="none";' alt='关闭本提示' />
			&nbsp;&nbsp;
		</div>
		<div style='width: 800px; margin: 0 auto; text-align: left; padding: 0; overflow: hidden; color: black;'>
			<div style='width: 75px; float: left;'><img src='/img/remind.jpg' alt='提示您升级浏览器' /></div>
			<div style='width: 275px; float: left; font-family: Arial, sans-serif;'>
				<div style='font-size: 14px; font-weight: bold; margin-top: 12px;'>提示：您还在用即将淘汰的IE 版本？</div>
				<div style='font-size: 12px; margin-top: 6px; line-height: 12px;'>为了获得更好的用户检验，请升级您的浏览器！<br />(从右边任选一个升级就不会出现本提示)</div>
			</div>
			<div style='float: left;margin-right:12px;margin-top:2px;'>
				<a href='https://www.baidu.com/s?wd=chrome' target='_blank'>
					<img src='~/img/browser-chrome.jpg' style='border: none;' alt='升级为Google公司的Chrome浏览器' class='os-chrome' />
				</a>
			</div>
			<div style='width: 75px; float: left;'>
				<a href='http://www.firefox.com' target='_blank'>
					<img src='~/img/browser-firefox.jpg' style='border: none;' alt='升级为Firefox浏览器' class='os-firefox' />
				</a>
			</div>
			<div style='width: 75px; float: left;'>
				<a href='http://chrome.360.cn/' target='_blank'>
					<img src='~/img/browser-360se.jpg' style='border: none;' alt='360极速浏览器' />
				</a>
			</div>
			<div style='width: 75px; float: left;'>
				<a href='https://ie.sogou.com/' target='_blank'>
					<img src='~/img/browser-sougou.jpg' style='border: none;' alt='搜狗浏览器' />
				</a>
			</div>
		</div>
	</div>
	<![endif]-->
	<form style="height: 100%" id="loginform">
		<div class="loginbg">
			<div class="login-midbg">
				<div style="font-size: 28px;display: flex;align-items: center;height: 80px;color: #fff;color: #f1f1f1;font-weight: bold;">
					@* <img src="~/img/login/logo.png" width="60px" height="60px" /> *@
					<div style="font-size: 36px;margin-top: -15px;padding-left: 10px;">
						创达加工管理平台
					</div>
				</div>
				<table width="293" border="0" class="login-tab">
					<tr>
						<td width="74" height="32" align="right">
							用户名：
						</td>
						<td width="209">
							<input type="text" class="login-put" name="uname" id="uname" value="" v-model.trim="ucode" />
						</td>
					</tr>
					<tr>
						<td height="32" align="right">
							密码：
						</td>
						<td>
							<input type="password" class="login-put" name="upasswd" id="upasswd" value="" v-model.trim="upasswd" @@keyup.enter="login" />
						</td>
					</tr>
					<tr>
						<td>
							&nbsp;
						</td>
						<td>
							<input type="button" value="登录" class="login-btn" @@click="login" :disabled="logging" />
							{{msg}}
						</td>
					</tr>
				</table>
			</div>
		</div>
	</form>
	<script src="~/lib/jquery-1.12.4.min.js" asp-append-version="true"></script>
	<environment include="Development">
		<script src="~/lib/vue-2.5.17.min.js" asp-append-version="true"></script>
	</environment>
	<environment exclude="Development">
		<script src="~/lib/vue-2.5.17.min.js" asp-append-version="true"></script>
	</environment>
	<script src="~/js/app.js" asp-append-version="true"></script>
	<script>
		localStorage.clear();
		sessionStorage.clear();
		var page = new Vue({
			el: '#loginform',
			data: {
				msg: '',
				ucode: '',
				upasswd: '',
				logging: false
			},
			methods: {
				reset: function (e) {
					this.msg = "";
				},
				validateNull:function(name, title) {
					if (!this[name] || this[name].length == 0) {
						this.msg = title + '不能为空';
						return false;
					} else {
						this.msg = '';
					}
					return true;
				},
				validateMinLength:function(name, title, length) {
					if (!this[name] || this[name].length == 0) {
						this.msg = title + '最少' + length + '位';
						return false;
					} else {
						this.msg = '';
					}
					return true;
				},
				validate: function () {
					if (!this.validateNull('ucode', '用户名') ||
						!this.validateNull('upasswd', '密码')) {
						return false;
					}
					//if (!/^1[345789]\d{9}$/.test(this.mobile)) {
					//	this.msg = '手机号有误';
					//	return false;
					//}
					return true;
				},
				login: function (e) {
					if (!this.validate()) {
						return;
					}
					this.logging = true;
					var _this = this;
					utils.ajaxPost('@Url.Action("Login", "Sys_User")', { ucode: _this.ucode, upasswd: _this.upasswd }, function (resp) {
						_this.logging = false;
						localStorage.setItem(globalData.baseUrl+"uinfo", JSON.stringify(resp.data));
						location.href='@Url.Action("Index", "Home")';
					}, function (msg) {
						_this.logging = false;
						_this.msg = msg || "登录失败，请检查参数或稍后再试";
					});
				}
			}
		});

		$(function () {
			if(isMobile())
			{
				window.location.href="@Url.Action("MobileLogin", "Sys_User")";
			}
			$('#uname').focus();
		});

		function isMobile() {
		  const regExp = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i;
		  return regExp.test(navigator.userAgent);
		}
	</script>
</body>
</html>
